﻿ <%@ WebHandler Language="C#" Class="ShopPKHandler" %>

using System;
using System.Web;
using Activity;
using Activity.API;

public class ShopPKHandler : BaseHandler
{

    public ShopPKHandler()
    {
        //修改请求为post 方式
        base._httpReuqest = base.Context.Request.Form;
    }

    public void GetFestivalList()
    {
        var handler = new CalendarHandler();
        var yearStr = _httpReuqest["Year"];
        var year = DateTime.Now.Year;
        if (!string.IsNullOrEmpty(yearStr))
            year = Convert.ToInt32(yearStr);
        var result = handler.GetFestivalList(year);
        if (result == null)
        {
            Error("获取数据异常");
        }
        else
        {
            Success(result);
        }
    }

    public void ModifyCalendar()
    {
        var handler = new CalendarHandler();
        var json = _httpReuqest["Json"];
        if (string.IsNullOrEmpty(json))
        {
            Error("保存失败!");
        }
        else
        {
            var result = handler.ModifyCalendar(json);
            if (result)
            {
                Success("保存成功!");
            }
            else
            {
                Error("保存失败!");
            }
        }
    }

    public void GetConditions()
    {
        var handler = new ShopGroupAndTargetHandler();
        var result = handler.GetConditions();
        if (result == null)
        {
            Error("获取数据异常");
        }
        else
        {
            Success(result);
        }
    }

    public void GetShopGroupAndTarget()
    {
        var operationAreaName = _httpReuqest["OperationAreaName"];
        var provincesName = _httpReuqest["ProvincesName"];
        var regionalManager = _httpReuqest["RegionalManager"];
        var shopManager = _httpReuqest["ShopManager"];
        var shopStr = _httpReuqest["ShopStr"];
        var rows = _httpReuqest["rows"];
        var page = _httpReuqest["page"];
        var handler = new ShopGroupAndTargetHandler();
        var result = handler.GetShopGroupAndTarget(operationAreaName, provincesName, regionalManager, shopManager,
            shopStr, Convert.ToInt32(rows), Convert.ToInt32(page));
        if (result != null)
        {
            Success(result);
        }
        else
        {
            Error("获取出错");
        }
    }

    public void ImportShopPermissionsList()
    {
        var jsonData = _httpReuqest["jsonData"];
        var handler = new ShopGroupAndTargetHandler();
        var result = handler.ImportShopGroupAndTarget(jsonData);
        if (result == 0)
        {
            Success(result);
        }
        else
        {
            Error("导入出错!");
        }
    }

}